package com.amsp.oa.oademo.service.impl;

import com.amsp.oa.oademo.entity.EmployeeAgreement;
import com.amsp.oa.oademo.mapper.EmployeeAgreementMapper;
import com.amsp.oa.oademo.service.EmployeeAgreementService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;

@Service
public class EmployeeAgreementServiceImpl extends ServiceImpl<EmployeeAgreementMapper, EmployeeAgreement>
        implements EmployeeAgreementService {

    @Override
    public IPage<EmployeeAgreement> getPage(Integer current, Integer size, String employeeName,
            String departmentPosition) {
        LambdaQueryWrapper<EmployeeAgreement> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(employeeName)) {
            wrapper.like(EmployeeAgreement::getEmployeeName, employeeName);
        }
        if (StringUtils.hasText(departmentPosition)) {
            wrapper.like(EmployeeAgreement::getDepartmentPosition, departmentPosition);
        }

        wrapper.orderByDesc(EmployeeAgreement::getCreateTime);

        return page(new Page<>(current, size), wrapper);
    }


}